package com.secondriver.url.filter

import java.util.Properties;
import java.io.InputStream;
import java.lang.ClassLoader;

class SysConfig{

	def SysConfig(){
	}

	def Properties getSqlScript(){
		def sqlScript=new Properties();
		def is=this.getClass().getResourceAsStream(this.constant.configFile);
		sqlScript.load(is.newReader("UTF-8"));
		is.close();
		return sqlScript;
	}

	/**
	 * sql.open:开放的URL
	 * sql.permit:权限控制的URL
	 */
	def  sql=[
		open:'''select f_url.* from f_url where f_url.status=:status ''',
		permit:'''
			select f_url.* from f_url where f_url.status=:status and f_url.urlid in(
				select f_url_group.urlid from f_url_group
				where f_url_group.groupid in(
					select f_subject_group.groupid from f_subject_group
					where f_subject_group.subjectid=:subjectid
				)
			)
			'''
	];

	def supportDB=['postgres', 'mysql', 'sqlserver'];
	def supportTable=['f_url', 'f_group', 'f_url_group', 'f_subject_group'];


	/**
	 * status.open:开放状态
	 * status.on:启用URL权限控制
	 * status.off：关闭URL权限控制
	 */
	def status=[
		open:'-1',
		on:'1',
		off:'0'
	];

	def constant=[
		tokenzie:'|',
		configSep:'=',
		configFile:'/com/secondriver/url/filter/sqlscript.properties'
	]
}
